<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="/common/user.jsp"%>
<%
	/**
	 * 检验详细
	 */
	String sampleNo = input.getDesc("sample_no", "");
	Integer branch = input.getInt("branch", 1);
	Where where = new Where("sampleNo=", sampleNo);
	if (hospital != 999)
		where.and("hospital=", hospital).and("branch=", branch);
	String selectContent = "new map(sampleNo as sample_no, parentItemName as parent_name, receiveTime as create_time, itemName as name, result as result, itemUnit as unit, referDesc as reference_value, description as desc)";
	List<Map> patientList = QBuilder.db("basedb").select(selectContent).from("Examine").where(where).query().getResultObj();
	if (patientList.size() == 0) {
		msg.put("data", Collections.emptyMap());
		Tools.encryptPrint(out, msg);
		return;
	}	
	Map<String, String> title = new HashMap<String, String>();
	for (int i = 0; i < patientList.size(); i++) {
		Map m = (Map)patientList.get(i);
		String time = (String)m.remove("create_time");
		String parentName = (String)m.remove("parent_name");
		sampleNo = (String)m.remove("sample_no");
		title.put("time", time);
		title.put("parent_name", parentName);
		title.put("sample_no", sampleNo);
		String desc = Tools.getDesc(m.get("desc"), "");
		m.put("desc", desc);
	}
	Collections.sort(patientList, new Comparator<Map>() {
            public int compare(Map o1, Map o2) {
                return Tools.getDesc(o2.get("desc")).compareTo(Tools.getDesc(o1.get("desc")));
            }
        });
	Map result = new HashMap();
	result.put("report", patientList);
	result.put("title", title);
	msg.put("data", result);
	Tools.encryptPrint(out, msg);
%>
